package
{
	import flash.utils.IDataInput;
	import flash.utils.IDataOutput;
	
	import org.musince.logic.ISerializable;
	
	public class DataPlayer implements ISerializable
	{
		public var json:Object;
		
		public var name:String = "none";
		
		public var country:int;
		public var profession:int;
		public var sex:int;
		public var level:int;
		public var hpMax:int;
		public var mpMax:int;
		
		public var attack:int;
		public var speed:int;
		
		public var defense:int;
		public var defenseBreak:int;
		
		public var dodge:int;
		public var hit:int;
		
		public var critical:int;
		public var criticalBreak:int;	
		
		public var skills:Array = [];
		public var equips:Array = [];
		
		public var score:int;
		public var ranking:int;
		public var grade:int;
		public var group:int;
		
		public function DataPlayer()
		{
//			name = json.name;
//			
//			country = json.name;
//			profession = json.profession;
//			sex = json.sex;
//			level = json.level;
//			hpMax:;
//			mpMax:int;
//			
//			attack:int;
//			speed:int;
//			
//			defense:int;
//			defenseBreak:int;
//			
//			dodge:int;
//			hit:int;
//			
//			critical:int;
//			criticalBreak:int;
		}
		
		public function serialize(buf:IDataOutput):void
		{
			buf.writeUTF(name);
			
			buf.writeInt(profession);
			buf.writeInt(sex);
			buf.writeInt(level);
			buf.writeInt(hpMax);
			buf.writeInt(mpMax);
			
			buf.writeInt(attack);
			buf.writeInt(speed);
			
			buf.writeInt(defense);
			buf.writeInt(defenseBreak);
			
			buf.writeInt(dodge);
			buf.writeInt(hit);
			
			buf.writeInt(critical);
			buf.writeInt(criticalBreak);
			
			buf.writeInt(country);
			
			buf.writeInt(skills.length);
			for each(var skill:int in skills) {
				buf.writeInt(skill);
			}
			
			buf.writeInt(equips.length);
			for each(var equip:int in equips) {
				buf.writeInt(equip);
			}
		}
		
		public function unserialize(buf:IDataInput):void
		{
			name = buf.readUTF();
			
			profession = buf.readInt();
			sex = buf.readInt();
			level = buf.readInt();
			hpMax = buf.readInt();
			mpMax = buf.readInt();
			
			attack = buf.readInt();
			speed = buf.readInt();
			
			defense = buf.readInt();
			defenseBreak = buf.readInt();
			
			dodge = buf.readInt();
			hit = buf.readInt();
			
			critical = buf.readInt();
			criticalBreak = buf.readInt();
			
			country =  buf.readInt();		
			
			var size:int = buf.readByte();
			skills = new Array(size);
			for (var i:int = 0; i < size; i++) {
				skills[i] = buf.readInt();
			}
			
			size = buf.readByte();
			equips = new Array(size);
			for (i = 0; i < size; i++) {
				equips[i] = buf.readInt();
			}
			
			score = buf.readInt();
			ranking = buf.readInt();
			grade = buf.readInt();
		}
	}
}